Listener = cc.Class.extend({
	ok:false,
	ctor: function(){
	},
	executeDown: function(pos,target){
		this.ok = false;
		if(!synch_listener){
			return;
		}
		var teach_flow = gg.flow;
		var flow = teach_flow.flow;
		var sheet = target.runSpriteSheet;
		
		if(target.lamp.isVisible()){
			this.downLamp(target, pos, teach_flow, flow);
		} else if(target.atomic2.isVisible()){
			this.downAtomic(target, pos, teach_flow, flow);
		} else if(target.aawin.isVisible()){
			this.downAAWin(target, pos, teach_flow, flow);
		} else if(target.air_lite.isVisible()){
			this.downAir(target, pos, teach_flow, flow);
		} else if(flow.TAG_RUN_DESK && this.checkPoint(sheet,TAG_RUN_DESK,pos)){
			cc.log("桌子被点击了");
			this.duang();
		} else if(flow.TAG_RUN_HOST && this.checkPoint(sheet,TAG_RUN_HOST, pos)){
			cc.log("主机被点击了");
			this.duang();
		} else if(flow.TAG_HOST_OPEN && this.checkPoint(sheet,TAG_HOST_OPEN, pos)){
			cc.log("电脑开机了");
			this.duang();
			sheet.getChildByTag(TAG_HOST_OPEN).setSpriteFrame("host_open.png");
			sheet.getChildByTag(TAG_RUN_COMPER).setSpriteFrame("comper_open.png");
			teach_flow.next();
		} else if(flow.TAG_RUN_COMPER && this.checkPoint(sheet,TAG_RUN_COMPER, pos)){
			cc.log("电脑被点击了,AAWin已打开");
			this.duang();
			target.aawin.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_RUN_ATOMIC && this.checkPoint(sheet,TAG_RUN_ATOMIC, pos)){
			cc.log("原子吸收被点击了");
			var rect = sheet.getChildByTag(TAG_RUN_ATOMIC).getBoundingBox();
			if(this.checkPoint2(new cc.rect(rect.x, rect.y, rect.width * 0.2, rect.height),pos)){
				cc.log("侧面玻璃罩被点击了");	
				this.duang();
				target.lamp.setVisible(true);
				teach_flow.next();
			}
		} else if(flow.TAG_RUN_ATOMIC_P && this.checkPoint(sheet,TAG_RUN_ATOMIC,pos)){
			var rect = sheet.getChildByTag(TAG_RUN_ATOMIC_P).getBoundingBox();
			if(this.checkPoint2(new cc.rect(rect.x + rect.width * 0.3, rect.y, rect.width * 0.5, rect.height * 0.5),pos)){
				cc.log("蓝色盖子被点击了");
				this.duang();
				sheet.getChildByTag(TAG_RUN_ATOMIC_P).setVisible(true);
				teach_flow.next();
			}
		} else if(flow.TAG_RUN_POWER && this.checkPoint(sheet,TAG_RUN_POWER, pos)){
			cc.log("电源主机被点击了");
			this.duang();
		} else if(flow.TAG_RUN_GAS && this.checkPoint(sheet,TAG_RUN_GAS, pos)){
			cc.log("气瓶柜被点击了");
			this.duang();
			sheet.getChildByTag(TAG_RUN_GAS).setSpriteFrame("gas2.png");
			sheet.getChildByTag(TAG_GAS_TABLE).setVisible(true);
			sheet.getChildByTag(TAG_GAS_POINT).setVisible(true);
			sheet.getChildByTag(TAG_GAS_RUNNER).setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_GAS_RUNNER && this.checkPoint(sheet,TAG_GAS_RUNNER, pos)){
			cc.log("气瓶柜转动了");
			this.duang();
			if(sheet.getChildByTag(TAG_GAS_POINT).isOpen){
				sheet.getChildByTag(TAG_GAS_POINT).turn_in_gas(2,-80,teach_flow);
			} else {
				sheet.getChildByTag(TAG_GAS_POINT).turn_in_gas(2,80,teach_flow);				
			}
		} else if(flow.TAG_RUN_AIR && this.checkPoint(sheet,TAG_RUN_AIR, pos)){
			cc.log("气压机被点击了");
			this.duang();
			target.air_lite.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_RUN_BEAKER && this.checkPoint(sheet,TAG_RUN_BEAKER, pos)){
			cc.log("烧杯1被点击了");
			this.duang();
			if(!sheet.getChildByTag(TAG_RUN_BEAKER).hasSolute){
				sheet.getChildByTag(TAG_RUN_BEAKER).hasSolute = true;
				teach_flow.next();	
			} else {
				target.aawin.test_start.setVisible(true);
				sheet.getChildByTag(TAG_RUN_BEAKER).go(flaskX,flaskY,teach_flow);
				sheet.getChildByTag(TAG_RUN_BEAKER5).back();
			}
		} else if(flow.TAG_RUN_BEAKER2 && this.checkPoint(sheet,TAG_RUN_BEAKER2, pos)){
			cc.log("烧杯2被点击了");
			this.duang();
			if(!sheet.getChildByTag(TAG_RUN_BEAKER2).hasSolute){
				sheet.getChildByTag(TAG_RUN_BEAKER2).hasSolute = true;
				teach_flow.next();	
			} else {
				target.aawin.test_start.setVisible(true);
				sheet.getChildByTag(TAG_RUN_BEAKER2).go(flaskX,flaskY,teach_flow);
				sheet.getChildByTag(TAG_RUN_BEAKER).back();
			}
		} else if(flow.TAG_RUN_BEAKER3 && this.checkPoint(sheet,TAG_RUN_BEAKER3, pos)){
			cc.log("烧杯3被点击了");
			this.duang();
			if(!sheet.getChildByTag(TAG_RUN_BEAKER3).hasSolute){
				sheet.getChildByTag(TAG_RUN_BEAKER3).hasSolute = true;
				teach_flow.next();	
			} else {
				target.aawin.test_start.setVisible(true);
				sheet.getChildByTag(TAG_RUN_BEAKER3).go(flaskX,flaskY,teach_flow);
				sheet.getChildByTag(TAG_RUN_BEAKER2).back();
			}
		} else if(flow.TAG_RUN_BEAKER4 && this.checkPoint(sheet,TAG_RUN_BEAKER4, pos)){
			cc.log("烧杯4被点击了");
			this.duang();
			if(!sheet.getChildByTag(TAG_RUN_BEAKER4).hasSolute){
				sheet.getChildByTag(TAG_RUN_BEAKER4).hasSolute = true;
				teach_flow.next();	
			} else {
				target.aawin.test_start.setVisible(true);
				sheet.getChildByTag(TAG_RUN_BEAKER4).go(flaskX,flaskY,teach_flow);
				sheet.getChildByTag(TAG_RUN_BEAKER3).back();
			}
		} else if(flow.TAG_RUN_BEAKER5 && this.checkPoint(sheet,TAG_RUN_BEAKER5, pos)){
			cc.log("烧杯5被点击了");
			this.duang();
			sheet.getChildByTag(TAG_RUN_BEAKER5).go(flaskX,flaskY,teach_flow);
			target.aawin.test_zero.setVisible(true);
		} else if(flow.TAG_RUN_COOKER && this.checkPoint(sheet,TAG_RUN_COOKER, pos)){
			cc.log("油烟机被点击了");
			this.duang();
		} else {
			cc.log("点击事件");
			this.downAAWin2(target, pos, teach_flow, flow)
		}
		this.duang_error();
	},
	downLamp:/**
				 * 灯座点击事件
				 */
		function(target, pos, teach_flow, flow){
		if(flow.tag == TAG_ATOMIC_PART&&this.checkPoint2(target.atomic_part.diyRect, pos)){
			cc.log("圆盘被点击了");
			if(target.atomic_part.status==0){
				synch_listener = false;
				target.atomic_part.open(teach_flow);
				this.duang();
			} else if(target.atomic_part.status==1){
				synch_listener = false;
				target.atomic_part.close(teach_flow);
				this.duang();
			}
		} else if(flow.tag == TAG_LIGHT_CA&&this.checkPoint2(target.lamp.getChildByTag(flow.tag).diyRect, pos)){
			// 安装钙阴极灯，
			synch_listener = false;
			cc.log("安装钙阴极灯");
			var rect = target.atomic_part.diyRect;
			target.light_ca.install(rect.x * 0.42,rect.y+rect.height*0.3,teach_flow);
			this.duang();
		}
	},
	downAtomic:/**
				 * 电源点击事件
				 */
		function(target, pos, teach_flow, flow){
		if(flow.tag == TAG_ATOMIC_OPEN&&this.checkPoint2(target.atomic2.getChildByTag(flow.tag).diyRect, pos)){
			cc.log("电源开关打开了");
			this.duang();
			target.atomic2.getChildByTag(flow.tag).setSpriteFrame("atomic_open.png");
			target.atomic2.setVisible(false);
			teach_flow.next();
		}
	},
	downAAWin:function(target, pos, teach_flow, flow){
		aawin = target.aawin;
		if(flow.TAG_AAWIN_YIQI && !aawin.sel1 && !aawin.select.isVisible() && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_YIQI).getBoundingBox(), pos)){
			cc.log("选择栏打开了");
			this.duang();
			aawin.sel1 = true;
			aawin.button_yiqi.setVisible(false);
			aawin.select.setVisible(true);
			aawin.e_lamp.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_ELAMP && aawin.select.isVisible()&& this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_ELAMP).getBoundingBox(), pos)){
			cc.log("元素灯选择栏打开了");
			this.duang();
			aawin.select.setVisible(false);
			aawin.e_lamp.setVisible(false);
			aawin.select_lamp.setVisible(true);
			aawin.button_next.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_NEXT && !aawin.e_param && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_NEXT).getBoundingBox(), pos)){
			cc.log("设置元素测量参数");
			this.duang();
			aawin.e_param = true;
			aawin.select_lamp.setSpriteFrame("set_e_param.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_NEXT && !aawin.w_param && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_NEXT).getBoundingBox(), pos)){
			cc.log("设置波长");
			this.duang();
			aawin.w_param = true;
			aawin.select_lamp.setSpriteFrame("set_w_param.png");
			aawin.button_next.setVisible(false);
			aawin.button_peak.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_PEAK && !aawin.state1 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_PEAK).getBoundingBox(), pos)){
			cc.log("寻峰1");
			this.duang();
			aawin.state1 = true;
			aawin.s_peak.setVisible(true);
			aawin.button_peak.setPosition(gg.width * 0.85, gg.height * 0.425 + 4);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_PEAK && !aawin.state2 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_PEAK).getBoundingBox(), pos)){
			cc.log("寻峰2");
			this.duang();
			aawin.state2 = true;
			aawin.button_peak.setVisible(false);
			aawin.button_close.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_CLOSE && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_CLOSE).getBoundingBox(), pos)){
			cc.log("寻峰结束，关闭");
			this.duang();
			aawin.s_peak.setVisible(false);
			aawin.button_close.setVisible(false);
			aawin.button_next.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_NEXT && !aawin.w_param2 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_NEXT).getBoundingBox(), pos)){
			cc.log("设置波长结束，下一步");
			this.duang();
			aawin.w_param2 = true;
			aawin.button_next.setVisible(false);
			aawin.button_finish.setVisible(true);
			aawin.select_lamp.setSpriteFrame("set_finish.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_FINISH && !aawin.finish1 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_FINISH).getBoundingBox(), pos)){
			cc.log("参数设置结束，结束");
			this.duang();
			aawin.finish1 = true;
			aawin.button_finish.setVisible(false);
			aawin.select_lamp.setVisible(false);
			aawin.button_yiqi.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_YIQI && !aawin.sel2 && !aawin.select.isVisible() && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_YIQI).getBoundingBox(), pos)){
			cc.log("测量方法");
			this.duang();
			aawin.sel2 = true;
			aawin.button_yiqi.setVisible(false);
			aawin.select.setVisible(true);
			aawin.celiang.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_CELIANG && aawin.select.isVisible() && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_CELIANG).getBoundingBox(), pos)){
			cc.log("进入测量方法界面");
			this.duang();
			aawin.celiang.setVisible(false);
			aawin.button_sure.setVisible(true);
			aawin.param_set.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_SURE && !aawin.sure1 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_SURE).getBoundingBox(), pos)){
			cc.log("测量方法设置结束");
			this.duang();
			aawin.sure1 = true;
			aawin.button_sure.setVisible(false);
			aawin.param_set.setVisible(false);
			aawin.select.setVisible(false);
			aawin.button_yiqi.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_YIQI && !aawin.sel3 && !aawin.select.isVisible() && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_YIQI).getBoundingBox(), pos)){
			cc.log("燃烧器参数");
			this.duang();
			aawin.sel3 = true;
			aawin.button_yiqi.setVisible(false);
			aawin.ranshao.setVisible(true);
			aawin.select.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_RANSHAO && aawin.select.isVisible() && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_RANSHAO).getBoundingBox(), pos)){
			cc.log("进入燃烧器参数界面");
			this.duang();
			aawin.select.setVisible(false);
			aawin.ranshao.setVisible(false);
			aawin.button_sure.setVisible(true);
			aawin.param_set.setVisible(true);
			aawin.param_set.setSpriteFrame("ranshao_set.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_SURE && !aawin.sure2 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_SURE).getBoundingBox(), pos)){
			aawin.sure2 = true;
			cc.log("燃烧器参数设置结束");
			this.duang();
			aawin.button_sure.setVisible(false);
			aawin.param_set.setVisible(false);
			aawin.param.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_PARAM && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_PARAM).getBoundingBox(), pos)){
			cc.log("打开参数设置界面");
			this.duang();
			aawin.param.setVisible(false);
			aawin.param_lay.setVisible(true);
			aawin.info_exe.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_INFO && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_INFO).getBoundingBox(), pos)){
			cc.log("进入信息处理TAB页");
			this.duang();
			aawin.info_exe.setVisible(false);
			aawin.button_sure.setPosition(gg.width * 0.62 + 6, gg.height * 0.065 + 10);
			aawin.button_sure.setVisible(true);
			aawin.param_lay.setSpriteFrame("param_lay2.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_SURE && !aawin.sure3 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_SURE).getBoundingBox(), pos)){
			cc.log("参数设置结束");
			this.duang();
			aawin.sure3 = true;
			aawin.button_sure.setVisible(false);
			aawin.param_lay.setVisible(false);
			aawin.sample.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_SAMPLE && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_SAMPLE).getBoundingBox(), pos)){
			cc.log("弹出样品界面1");
			this.duang();
			aawin.sample.setVisible(false);
			aawin.sample_guide.setVisible(true);
			aawin.button_next.setPosition(gg.width * 0.55 + 3, gg.height * 0.16 + 5);
			aawin.button_next.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_NEXT && !aawin.sample1 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_NEXT).getBoundingBox(), pos)){
			cc.log("样品界面2");
			this.duang();
			aawin.sample1 = true;
			aawin.sample_guide.setSpriteFrame("sample_guide2.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_NEXT && !aawin.sample2 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_NEXT).getBoundingBox(), pos)){
			cc.log("样品界面3");
			this.duang();
			aawin.sample2 = true;
			aawin.sample_guide.setSpriteFrame("sample_guide3.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_NEXT && !aawin.sample3 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_NEXT).getBoundingBox(), pos)){
			cc.log("样品界面4");
			this.duang();
			aawin.sample_guide.setSpriteFrame("sample_guide4.png");
			aawin.sample3 = true;
			aawin.button_next.setVisible(false);
			aawin.button_finish.setPosition(gg.width * 0.65 + 5, gg.height * 0.16 + 3);
			aawin.button_finish.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_FINISH && !aawin.finish2 && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_FINISH).getBoundingBox(), pos)){
			cc.log("样品设置结束");
			this.duang();
			aawin.finish2 = true;
			aawin.sample_guide.setVisible(false);
			aawin.setVisible(false);
			aawin.button_finish.setVisible(false);
			aawin.fire_up.setVisible(true);
			aawin.sample_list.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_FIREUP && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_FIREUP).getBoundingBox(), pos)){
			cc.log("点火");
			this.duang();
			aawin.aawinSprite.getChildByTag(TAG_AAWIN_FIREUP).setVisible(false);
			aawin.energy.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_ENERGY && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_ENERGY).getBoundingBox(), pos)){
			this.duang();
			aawin.energy.setVisible(false);
			aawin.energy_debug.setVisible(true);
			aawin.energy_point.setVisible(true);
			aawin.energy_auto.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_EAUTO && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_EAUTO).getBoundingBox(), pos)){
			this.duang();
			aawin.energy_auto.setVisible(false);
			aawin.energy_point.turn_in_energy(2, 90, teach_flow);
		} else if(flow.TAG_AAWIN_ECLOSE && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_ECLOSE).getBoundingBox(), pos)){
			this.duang();
			aawin.energy_close.setVisible(false);
			aawin.energy_point.setVisible(false);
			aawin.energy_debug.setVisible(false);
			aawin.test.setVisible(true);
			// 能量改为100
			aawin.energy.setSpriteFrame("energy_100.png");
			teach_flow.next();
		} else if(flow.TAG_AAWIN_TEST && this.checkPoint2(aawin.aawinSprite.getChildByTag(TAG_AAWIN_TEST).getBoundingBox(), pos)){
			cc.log("打开测量框");
			this.duang();
			aawin.test_dialog.setVisible(true);
			aawin.setVisible(false);
			teach_flow.next();
		} 
	},
	downAAWin2:function(target, pos, teach_flow, flow){
		aawin = target.aawin;
		if(flow.TAG_AAWIN_ZERO && this.checkPoint2(aawin.test_zero.getBoundingBox(), pos)){
			cc.log("调零");
			this.duang();
			aawin.test_zero.setVisible(false);
			aawin.test_start.setVisible(true);
			teach_flow.next();
		} else if(flow.TAG_AAWIN_START && this.checkPoint2(aawin.test_start.getBoundingBox(), pos)){
			cc.log("开始");
			this.duang();
			aawin.test_start.setVisible(false);
			teach_flow.next();
		}
	},
	downAir:function(target, pos, teach_flow, flow){
		air_lite = target.air_lite;
		if(flow.TAG_AIR_OPEN && this.checkPoint2(air_lite.getChildByTag(TAG_AIR_OPEN).diyRect, pos)){
			if(!air_lite.open){
				cc.log("空气压缩机打开了");
				this.duang();
				air_lite.open = true;
				air_lite.getChildByTag(TAG_AIR_OPEN).setSpriteFrame("air_open.png");				
			} else {
				cc.log("空气压缩机关闭了");
				this.duang();
				air_lite.getChildByTag(TAG_AIR_OPEN).setSpriteFrame("air_close.png");
				air_lite.setVisible(false);
			}
			teach_flow.next();
		} else if(flow.TAG_AIR_VALVE && this.checkPoint2(air_lite.getChildByTag(TAG_AIR_VALVE).diyRect, pos)){
			cc.log("转动调压阀");
			this.duang();
			if(!air_lite.has_air){
				air_lite.has_air = true;
				target.air_point.turn_in_air(2,100,teach_flow);
			} else {
				target.air_point.turn_in_air(2,-100,teach_flow);
			}
		}
	},
	checkPoint:function(object,TAG,pos){
		var rect = object.getChildByTag(TAG).getBoundingBox();
		return this.checkPoint2(rect, pos);
	},
	checkPoint2:function(rect,pos){
		var sc = 0.2;
		rect = cc.rect(rect.x - rect.width * sc, rect.y -rect.height * sc, rect.width * (1 + sc),rect.height* (1 + sc));
		return cc.rectContainsPoint(rect, pos);
	},
	duang:function(){
		this.ok = true;
		ll.tip.mdScore(10);
		_.clever();
	},
	duang_error:function(){
		if(!this.ok){
			ll.tip.mdScore(-3);
			_.error();
		}
	}
});
